import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import { BookEntity } from "./book.entity";

@Entity('chapters')
export class ChaptersEntity {
  @PrimaryGeneratedColumn({ name: 'id', comment: '主键' })
  id: number;

  @ManyToOne(() => BookEntity, (book) => book.chapters)
  book: BookEntity;

  @Index(['bookId'])
  @Column({ name: 'bookId', comment: '书籍ID' })
  bookId: number;

  @Column({ name: 'chapterNumber', comment: '章节号' })
  chapterNumber: number;

  @Column({ name: 'title', comment: '章节标题' })
  title: string;

  @Column({ name: 'fileName', comment: '文件名' })
  fileName: string;

  @Column({ name: "filePath", comment: "文件路径" })
  filePath: string;
}